package com.ttdev.mmms.service.impl;

import com.ttdev.mmms.entity.MemberInfo;
import com.ttdev.mmms.repository.MemberRepository;
import com.ttdev.mmms.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class MemberServiceImpl implements MemberService{
    @Autowired
    private MemberRepository memberRepository;

    @Override
    public List<MemberInfo> findsAll(Integer storeId) {
        return memberRepository.findsAll(storeId);
    }

    @Override
    public List<MemberInfo> queryMember(Integer cardId) {
        List<MemberInfo> list = memberRepository.queryMember(cardId);
        return list;
    }

    @Override
    public MemberInfo findPwd(String username) {
        return memberRepository.findPwd(username);
    }

    // 添加
    @Override
    public int add(MemberInfo member) {
        int i = memberRepository.add(member);
        return i;
    }

    // 更改
    @Override
    public int update(MemberInfo member) {
        int i = memberRepository.update(member);
        return i;
    }

    // 删除
    @Override
    public int delete(Integer cardId) {
        int i = memberRepository.delete(cardId);
        return i;
    }

    // 查询用户名是否存在
    @Override
    public Integer selectMemberName(String user) {
        return memberRepository.selectMemberName(user);
    }

    @Override
    public int payment(Integer card,Double price) {
        int i = memberRepository.payment(card,price);
        return i;
    }

    @Override
    public int account(int cardId,int sId,double money,String type) {
        int i = memberRepository.account(cardId,sId,money,type);
        return i;
    }
}
